<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑商品展示</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        }
        .product-item {
            transition: all 0.3s ease;
        }
        .product-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
        }
        .drag-handle {
            cursor: move;
        }
    </style>
</head>
<body class="bg-gray-100">
    <div class="mx-auto max-w-[393px] h-[852px] bg-white relative overflow-hidden rounded-[40px] shadow-2xl">
        <!-- Status Bar -->
        <div class="bg-white px-6 pt-3 pb-2">
            <div class="flex justify-between items-center text-xs">
                <span class="font-semibold">9:41</span>
                <div class="flex space-x-1">
                    <i class="fas fa-signal"></i>
                    <i class="fas fa-wifi"></i>
                    <i class="fas fa-battery-full"></i>
                </div>
            </div>
        </div>

        <!-- Header -->
        <div class="bg-gradient-to-r from-green-600 to-emerald-600 px-4 py-3">
            <div class="flex items-center justify-between text-white">
                <a href="b2b-store-decoration.html" class="text-white">
                    <i class="fas fa-arrow-left text-lg"></i>
                </a>
                <h1 class="text-lg font-semibold">编辑商品展示</h1>
                <button onclick="saveProductDisplay()" class="text-white hover:opacity-80">
                    <i class="fas fa-save text-lg"></i>
                </button>
            </div>
        </div>

        <!-- Display Preview -->
        <div class="p-4 bg-gray-50 border-b border-gray-200">
            <h3 class="text-sm font-medium text-gray-700 mb-2">预览效果</h3>
            <div class="bg-white rounded-lg p-3 shadow-sm">
                <div class="grid grid-cols-2 gap-2" id="productPreview">
                    <div class="border border-gray-200 rounded-lg p-2">
                        <img src="https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=150&h=120&fit=crop" 
                             alt="商品1" class="w-full h-20 object-cover rounded mb-1">
                        <p class="text-xs font-medium">无线蓝牙耳机</p>
                        <p class="text-xs text-red-600">¥299</p>
                    </div>
                    <div class="border border-gray-200 rounded-lg p-2">
                        <img src="https://images.unsplash.com/photo-1542291026-7eec264c27ff?w=150&h=120&fit=crop" 
                             alt="商品2" class="w-full h-20 object-cover rounded mb-1">
                        <p class="text-xs font-medium">运动鞋</p>
                        <p class="text-xs text-red-600">¥599</p>
                    </div>
                </div>
            </div>
        </div>

        <!-- Product Management -->
        <div class="h-[calc(852px-320px)] overflow-y-auto pb-40">
            <!-- Product Selection -->
            <div class="p-4">
                <div class="flex items-center justify-between mb-3">
                    <h3 class="font-semibold flex items-center">
                        <span class="w-1 h-4 bg-green-600 mr-2 rounded-full"></span>
                        精选商品 (6/12)
                    </h3>
                    <button onclick="selectProducts()" class="text-green-600 text-sm hover:text-green-700">
                        <i class="fas fa-plus mr-1"></i>选择商品
                    </button>
                </div>

                <div class="space-y-3" id="productList">
                    <!-- Product 1 -->
                    <div class="product-item bg-white rounded-lg border border-gray-200 p-3">
                        <div class="flex items-center space-x-3">
                            <div class="drag-handle text-gray-400">
                                <i class="fas fa-grip-vertical"></i>
                            </div>
                            <img src="https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=60&h=60&fit=crop" 
                                 alt="商品1" class="w-12 h-12 object-cover rounded">
                            <div class="flex-1">
                                <div class="flex items-center justify-between mb-1">
                                    <p class="text-sm font-medium">无线蓝牙耳机</p>
                                    <span class="text-xs bg-green-100 text-green-600 px-2 py-1 rounded">热销</span>
                                </div>
                                <p class="text-xs text-gray-500">价格: ¥299 | 库存: 156</p>
                            </div>
                            <div class="flex space-x-2">
                                <button onclick="editProduct(1)" class="text-blue-600 hover:text-blue-700">
                                    <i class="fas fa-edit text-sm"></i>
                                </button>
                                <button onclick="removeProduct(1)" class="text-red-600 hover:text-red-700">
                                    <i class="fas fa-times text-sm"></i>
                                </button>
                            </div>
                        </div>
                    </div>

                    <!-- Product 2 -->
                    <div class="product-item bg-white rounded-lg border border-gray-200 p-3">
                        <div class="flex items-center space-x-3">
                            <div class="drag-handle text-gray-400">
                                <i class="fas fa-grip-vertical"></i>
                            </div>
                            <img src="https://images.unsplash.com/photo-1542291026-7eec264c27ff?w=60&h=60&fit=crop" 
                                 alt="商品2" class="w-12 h-12 object-cover rounded">
                            <div class="flex-1">
                                <div class="flex items-center justify-between mb-1">
                                    <p class="text-sm font-medium">运动鞋</p>
                                    <span class="text-xs bg-orange-100 text-orange-600 px-2 py-1 rounded">新品</span>
                                </div>
                                <p class="text-xs text-gray-500">价格: ¥599 | 库存: 89</p>
                            </div>
                            <div class="flex space-x-2">
                                <button onclick="editProduct(2)" class="text-blue-600 hover:text-blue-700">
                                    <i class="fas fa-edit text-sm"></i>
                                </button>
                                <button onclick="removeProduct(2)" class="text-red-600 hover:text-red-700">
                                    <i class="fas fa-times text-sm"></i>
                                </button>
                            </div>
                        </div>
                    </div>

                    <!-- Product 3 -->
                    <div class="product-item bg-white rounded-lg border border-gray-200 p-3">
                        <div class="flex items-center space-x-3">
                            <div class="drag-handle text-gray-400">
                                <i class="fas fa-grip-vertical"></i>
                            </div>
                            <img src="https://images.unsplash.com/photo-1523275335684-37898b6baf30?w=60&h=60&fit=crop" 
                                 alt="商品3" class="w-12 h-12 object-cover rounded">
                            <div class="flex-1">
                                <div class="flex items-center justify-between mb-1">
                                    <p class="text-sm font-medium">智能手表</p>
                                    <span class="text-xs bg-purple-100 text-purple-600 px-2 py-1 rounded">限量</span>
                                </div>
                                <p class="text-xs text-gray-500">价格: ¥1299 | 库存: 23</p>
                            </div>
                            <div class="flex space-x-2">
                                <button onclick="editProduct(3)" class="text-blue-600 hover:text-blue-700">
                                    <i class="fas fa-edit text-sm"></i>
                                </button>
                                <button onclick="removeProduct(3)" class="text-red-600 hover:text-red-700">
                                    <i class="fas fa-times text-sm"></i>
                                </button>
                            </div>
                        </div>
                    </div>

                    <!-- Product 4 -->
                    <div class="product-item bg-white rounded-lg border border-gray-200 p-3">
                        <div class="flex items-center space-x-3">
                            <div class="drag-handle text-gray-400">
                                <i class="fas fa-grip-vertical"></i>
                            </div>
                            <img src="https://images.unsplash.com/photo-1572635196237-14b3f281503f?w=60&h=60&fit=crop" 
                                 alt="商品4" class="w-12 h-12 object-cover rounded">
                            <div class="flex-1">
                                <div class="flex items-center justify-between mb-1">
                                    <p class="text-sm font-medium">笔记本电脑</p>
                                    <span class="text-xs bg-red-100 text-red-600 px-2 py-1 rounded">促销</span>
                                </div>
                                <p class="text-xs text-gray-500">价格: ¥4999 | 库存: 12</p>
                            </div>
                            <div class="flex space-x-2">
                                <button onclick="editProduct(4)" class="text-blue-600 hover:text-blue-700">
                                    <i class="fas fa-edit text-sm"></i>
                                </button>
                                <button onclick="removeProduct(4)" class="text-red-600 hover:text-red-700">
                                    <i class="fas fa-times text-sm"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Display Settings -->
            <div class="p-4">
                <h3 class="font-semibold mb-3 flex items-center">
                    <span class="w-1 h-4 bg-green-600 mr-2 rounded-full"></span>
                    展示设置
                </h3>
                <div class="bg-white rounded-lg border border-gray-200 p-4">
                    <div class="space-y-4">
                        <!-- Layout Type -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">布局样式</label>
                            <div class="grid grid-cols-2 gap-2">
                                <button class="p-3 border border-green-500 rounded-lg bg-green-50" onclick="selectLayout('grid')">
                                    <div class="grid grid-cols-2 gap-1 mb-2">
                                        <div class="w-full h-4 bg-gray-300 rounded"></div>
                                        <div class="w-full h-4 bg-gray-300 rounded"></div>
                                        <div class="w-full h-4 bg-gray-300 rounded"></div>
                                        <div class="w-full h-4 bg-gray-300 rounded"></div>
                                    </div>
                                    <p class="text-xs">网格布局</p>
                                </button>
                                <button class="p-3 border border-gray-300 rounded-lg" onclick="selectLayout('list')">
                                    <div class="space-y-1 mb-2">
                                        <div class="w-full h-2 bg-gray-300 rounded"></div>
                                        <div class="w-full h-2 bg-gray-300 rounded"></div>
                                        <div class="w-full h-2 bg-gray-300 rounded"></div>
                                    </div>
                                    <p class="text-xs">列表布局</p>
                                </button>
                            </div>
                        </div>

                        <!-- Columns -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">每行商品数</label>
                            <select id="productColumns" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent">
                                <option value="1">1个</option>
                                <option value="2" selected>2个</option>
                                <option value="3">3个</option>
                            </select>
                        </div>

                        <!-- Show Info -->
                        <div class="space-y-3">
                            <div class="flex items-center justify-between">
                                <span class="text-sm text-gray-700">显示价格</span>
                                <label class="relative inline-flex items-center cursor-pointer">
                                    <input type="checkbox" checked class="sr-only peer" id="showPrice">
                                    <div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-green-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-green-600"></div>
                                </label>
                            </div>
                            
                            <div class="flex items-center justify-between">
                                <span class="text-sm text-gray-700">显示库存</span>
                                <label class="relative inline-flex items-center cursor-pointer">
                                    <input type="checkbox" class="sr-only peer" id="showStock">
                                    <div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-green-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-green-600"></div>
                                </label>
                            </div>
                            
                            <div class="flex items-center justify-between">
                                <span class="text-sm text-gray-700">显示标签</span>
                                <label class="relative inline-flex items-center cursor-pointer">
                                    <input type="checkbox" checked class="sr-only peer" id="showTags">
                                    <div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-green-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-green-600"></div>
                                </label>
                            </div>
                        </div>

                        <!-- Sort Order -->
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">排序方式</label>
                            <select id="sortOrder" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent">
                                <option value="manual">手动排序</option>
                                <option value="price-low">价格从低到高</option>
                                <option value="price-high">价格从高到低</option>
                                <option value="sales">销量排序</option>
                                <option value="newest">最新上架</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Section Title -->
            <div class="p-4">
                <h3 class="font-semibold mb-3 flex items-center">
                    <span class="w-1 h-4 bg-green-600 mr-2 rounded-full"></span>
                    区块标题
                </h3>
                <div class="bg-white rounded-lg border border-gray-200 p-4">
                    <div class="space-y-4">
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">标题文字</label>
                            <input type="text" id="sectionTitle" value="精选商品" 
                                   class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent">
                        </div>
                        
                        <div>
                            <label class="block text-sm font-medium text-gray-700 mb-2">副标题</label>
                            <input type="text" id="sectionSubtitle" value="为您精心挑选的优质商品" 
                                   class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent">
                        </div>

                        <div class="flex items-center justify-between">
                            <span class="text-sm text-gray-700">显示"查看更多"按钮</span>
                            <label class="relative inline-flex items-center cursor-pointer">
                                <input type="checkbox" checked class="sr-only peer" id="showViewMore">
                                <div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-green-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-green-600"></div>
                            </label>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Fixed Bottom Action Bar -->
        <div class="absolute bottom-1 left-0 right-0 bg-white border-t border-gray-200 p-4">
            <div class="flex space-x-3">
                <button onclick="previewProductDisplay()" class="bg-gray-100 text-gray-700 font-medium px-4 py-3 rounded-xl hover:bg-gray-200 transition-colors">
                    <i class="fas fa-eye mr-2"></i>预览
                </button>
                <button onclick="saveProductDisplay()" class="flex-1 bg-gradient-to-r from-green-600 to-emerald-600 text-white font-medium py-3 rounded-xl shadow-lg hover:shadow-xl transition-all duration-200">
                    <i class="fas fa-save mr-2"></i>保存设置
                </button>
            </div>
        </div>
    </div>

    <script>
        // Product display management functions
        function selectProducts() {
            showToast('正在打开商品选择器...');
            setTimeout(() => {
                const productCount = prompt('请选择要添加的商品数量（1-6）:');
                if (productCount >= 1 && productCount <= 6) {
                    showToast(`正在添加 ${productCount} 个商品...`);
                    setTimeout(() => {
                        showToast('商品添加成功');
                        updateProductCount();
                    }, 1500);
                }
            }, 1000);
        }

        function editProduct(id) {
            const options = [
                '修改显示位置',
                '设置促销标签',
                '调整显示信息',
                '查看商品详情'
            ];
            
            const choice = prompt(`编辑商品选项：\n\n1. ${options[0]}\n2. ${options[1]}\n3. ${options[2]}\n4. ${options[3]}\n\n请输入序号 (1-4):`);
            
            if (choice >= 1 && choice <= 4) {
                showToast(`正在${options[choice - 1]}...`);
                setTimeout(() => {
                    showToast('编辑完成');
                }, 1000);
            }
        }

        function removeProduct(id) {
            if (confirm('确认从展示区域移除这个商品吗？\n\n移除后可以重新添加。')) {
                showToast('正在移除商品...');
                setTimeout(() => {
                    showToast('商品已移除');
                    updateProductCount();
                }, 1000);
            }
        }

        function updateProductCount() {
            const count = document.querySelectorAll('.product-item').length;
            document.querySelector('h3 .font-semibold').innerHTML = `
                <span class="w-1 h-4 bg-green-600 mr-2 rounded-full"></span>
                精选商品 (${count}/12)
            `;
        }

        function selectLayout(layout) {
            // Remove selected state from all buttons
            document.querySelectorAll('[onclick^="selectLayout"]').forEach(btn => {
                btn.className = 'p-3 border border-gray-300 rounded-lg';
            });
            
            // Add selected state to clicked button
            event.target.closest('button').className = 'p-3 border border-green-500 rounded-lg bg-green-50';
            
            showToast(`已选择${layout === 'grid' ? '网格' : '列表'}布局`);
        }

        function previewProductDisplay() {
            showToast('正在生成商品展示预览...');
            setTimeout(() => {
                showToast('预览功能开发中，敬请期待');
            }, 1000);
        }

        function saveProductDisplay() {
            const settings = {
                productColumns: document.getElementById('productColumns').value,
                showPrice: document.getElementById('showPrice').checked,
                showStock: document.getElementById('showStock').checked,
                showTags: document.getElementById('showTags').checked,
                sortOrder: document.getElementById('sortOrder').value,
                sectionTitle: document.getElementById('sectionTitle').value,
                sectionSubtitle: document.getElementById('sectionSubtitle').value,
                showViewMore: document.getElementById('showViewMore').checked
            };

            showToast('正在保存商品展示设置...');
            
            setTimeout(() => {
                showToast('商品展示设置保存成功！');
                setTimeout(() => {
                    window.location.href = 'b2b-store-decoration.html';
                }, 1000);
            }, 1500);
        }

        // Toast notification
        function showToast(message) {
            const toast = document.createElement('div');
            toast.className = 'fixed top-20 left-1/2 transform -translate-x-1/2 bg-gray-800 text-white px-4 py-2 rounded-lg text-sm z-50';
            toast.textContent = message;
            document.body.appendChild(toast);
            
            setTimeout(() => {
                toast.remove();
            }, 2000);
        }

        // Initialize page
        document.addEventListener('DOMContentLoaded', function() {
            showToast('商品展示编辑器已加载');
        });
    </script>
</body>
</html>